<?php
if (!defined('BASEPATH')) exit('No direct script access allowed');
?>

<!-- JavaScript -->
<script type="text/javascript" src="<?= base_url() ?>js/wufoo.js"></script>
<script src="<?= base_url() ?>js/chosen.jquery.js" type="text/javascript"></script>
<!-- CSS -->
<!--<link rel="stylesheet" type="text/css" href="<?= base_url() ?>css/form/form.css" media="screen, tv, projection" title="Default" />-->
<link rel="stylesheet" type="text/css" href="<?php echo base_url() ?>css/datepicker.css" media="screen, tv, projection" title="Default" />
<script type="text/javascript" src="<?= base_url() ?>js/datepicker.js"></script>
<link rel="stylesheet" href="<?php echo base_url() ?>css/chosen.css" />

<div id="container">
	<?
    //Setting Awal Value Jika Prosedur yang dilakukan adalah prosedur input biasa.
	$value = array(
		'nama_sekolah'			=> "",
		'department'			=> "",
		'alamat_sekolah1'		=> "",
		'alamat_sekolah2'		=> "",
		'no_tlp1'				=> "",
		'no_tlp11'				=> "",
		'no_tlp2'				=> "",
		'no_tlp22'				=> "",
		'fax1'					=> "",
		'fax2'					=> "",
		'website'				=> "",
		'email'					=> "",
		'isaktif'				=> "1",
		'foto'					=> "",
		'legend'				=> "Form Input Data Instansi",
		'info'					=> "Form input Data Instansi",
		'act_form'				=> "ms_namasekolah/insert_namasekolah"
	);
	
	//Setting Value pada form Jika melakukan prosedur Edit terhadap data tertentu.
	if($status == "edit"){
		foreach($rs_namasekolah->result() as $row){
			$value['id_sekolah'] = $row->ID_SEKOLAH;
			$value['department'] = $row->ID_DEPARTMENT;
			$value['nama_sekolah'] = $row->NAMA_SEKOLAH;
			$value['alamat_sekolah1'] = $row->ALAMAT_SEKOLAH_1;
			$value['alamat_sekolah2'] = $row->ALAMAT_SEKOLAH_2;
			$value['no_tlp1'] = $row->NO_TELEPON_1;
			$value['no_tlp11'] = $row->NO_TELEPON_11;
			$value['no_tlp2'] = $row->NO_TELEPON_2;
			$value['no_tlp22'] = $row->NO_TELEPON_22;
			$value['fax1'] = $row->FAX_1;
			$value['fax2'] = $row->FAX_2;
			$value['website'] = $row->WEBSITE;
			$value['email'] = $row->email;
			$value['isaktif'] = $row->ISAKTIF;
			$value['foto'] = $row->FOTO;
			$fileold = $row->FOTO;
		}
		$value['legend'] = "Form Input Data Instansi";
		$value['info'] = "Form Input Data Instansi";
		$value['act_form'] = "ms_namasekolah/edit_namasekolah/".$value['id_sekolah'];
	}//end if
	
	?>
	<?= form_open_multipart($value["act_form"],'class="wufoo" name="form_dataguru" enctype="multipart/form-data"'); ?>
	<fieldset class="fieldset">
	<legend class="legend">
		<?= $value["legend"] ?> |
	</legend>
	
	<div class="info">
		<div><?= $value["info"] ?></div>
	</div>
	<div>
		<?= anchor(site_url('ms_namasekolah'),img(array('src'=>'images/main/38.png','border'=>'0','alt'=>'')).' Kembali ke daftar Instansi','Menampilkan halaman Daftar Instansi'); ?>
	</div>
 <!-- Konten -------------------------------------------------------------------------->
 <div id="contentform">
	<ul>
		<li>
			<label class="desc">Nama Instansi *</label>
			<div>
				<input class="field text" type="text" maxlength="50" size="50" name="nama_sekolah" value="<? if(set_value('nama_sekolah')!='') echo set_value('nama_sekolah'); else echo $value['nama_sekolah'];?>"/> 
			</div>
			<p class="instruct">
				Masukkan Nama Instansi Pada Kolom ini.			
			</p>
		</li>
		<?php echo form_error('nama_sekolah'); ?>
		
		<li>
			<label class="desc">Department </label>
			 <div>
                <? 
                //list department
				$options_department[''] = "-- Pilih department --";
				foreach($dept->result() as $rows){
					$options_department[$rows->ID_DEPARTMENT] = $rows->NAMA_DEPARTMENT; 
				}
				echo form_dropdown('department',$options_department,$value['department'],'class="field select"');	
                ?>
            </div>
			<p class="instruct">
				Pilih Department pada Kolom ini.			
			</p>
		</li>
		<?php echo form_error('department'); ?>
		
		<li>
			<label class="desc">Alamat Instansi 1*</label>
			<div>
				<input class="field text" type="text" maxlength="100" size="100" name="alamat_sekolah1" value="<? if(set_value('alamat_sekolah1')!='') echo set_value('alamat_sekolah1'); else echo $value['alamat_sekolah1'];?>"/> 
			</div>
			<p class="instruct">
				Masukkan Alamat Instansi 1 Pada Kolom ini.			
			</p>
		</li>
		<?php echo form_error('alamat_sekolah1'); ?>
		
		<li>
			<label class="desc">No. Tlp 1*</label>
			<div>
				<input class="field text" type="text" maxlength="12" size="12" name="no_tlp1" value="<? if(set_value('no_tlp1')!='') echo set_value('no_tlp1'); else echo $value['no_tlp1'];?>"/> 
			</div>
			<p class="instruct">
				Masukkan No. TELPON Pada Kolom ini.			
			</p>
		</li>
		<?php echo form_error('no_tlp1'); ?>
		
		<li>
			<label class="desc">No. HP 1</label>
			<div>
				<input class="field text" type="text" maxlength="12" size="12" name="no_tlp11" value="<? if(set_value('no_tlp11')!='') echo set_value('no_tlp11'); else echo $value['no_tlp11'];?>"/> 
			</div>
			<p class="instruct">
				Masukkan No. HP Pada Kolom ini.			
			</p>
		</li>
		<?php echo form_error('no_tlp11'); ?>
		
		<li>
			<label class="desc">Fax 1</label>
			<div>
				<input class="field text" type="text" maxlength="12" size="12" name="fax1" value="<? if(set_value('fax1')!='') echo set_value('fax1'); else echo $value['fax1'];?>"/> 
			</div>
			<p class="instruct">
				Masukkan Fax 1 Pada Kolom ini.			
			</p>
		</li>
		<?php echo form_error('fax1'); ?>
		
		<li>
			<label class="desc">Alamat Instansi 2</label>
			<div>
				<input class="field text" type="text" maxlength="100" size="100" name="alamat_sekolah2" value="<? if(set_value('alamat_sekolah2')!='') echo set_value('alamat_sekolah2'); else echo $value['alamat_sekolah2'];?>"/> 
			</div>
			<p class="instruct">
				Masukkan Alamat Instansi 2 Pada Kolom ini.			
			</p>
		</li>
		<?php echo form_error('alamat_sekolah2'); ?>
		
		<li>
			<label class="desc">No. Tlp 2</label>
			<div>
				<input class="field text" type="text" maxlength="12" size="12" name="no_tlp2" value="<? if(set_value('no_tlp2')!='') echo set_value('no_tlp2'); else echo $value['no_tlp2'];?>"/> 
			</div>
			<p class="instruct">
				Masukkan No. TELPON 2 Pada Kolom ini.			
			</p>
		</li>
		<?php echo form_error('no_tlp2'); ?>
		
		<li>
			<label class="desc">No. HP 2</label>
			<div>
				<input class="field text" type="text" maxlength="12" size="12" name="no_tlp22" value="<? if(set_value('no_tlp22')!='') echo set_value('no_tlp22'); else echo $value['no_tlp22'];?>"/> 
			</div>
			<p class="instruct">
				Masukkan No. HP 2 Pada Kolom ini.			
			</p>
		</li>
		<?php echo form_error('no_tlp22'); ?>
		
		<li>
			<label class="desc">Fax 2</label>
			<div>
				<input class="field text" type="text" maxlength="12" size="12" name="fax2" value="<? if(set_value('fax2')!='') echo set_value('fax2'); else echo $value['fax2'];?>"/> 
			</div>
			<p class="instruct">
				Masukkan Fax 2 Pada Kolom ini.			
			</p>
		</li>
		<?php echo form_error('fax2'); ?>
		
		<li>
			<label class="desc">Website</label>
			<div>
				<input class="field text" type="text" maxlength="50" size="50" name="website" value="<? if(set_value('website')!='') echo set_value('website'); else echo $value['website'];?>"/> 
			</div>
			<p class="instruct">
				Masukkan Website Pada Kolom ini.			
			</p>
		</li>
		<?php echo form_error('website'); ?>
		
		<li>
			<label class="desc">Email</label>
			<div>
				<input class="field text" type="text" maxlength="50" size="50" name="email" value="<? if(set_value('email')!='') echo set_value('email'); else echo $value['email'];?>"/> 
			</div>
			<p class="instruct">
				Masukkan Email Pada Kolom ini.			
			</p>
		</li>
		<?php echo form_error('email'); ?>
		
		<li>
			<label class="desc">Aktif?</label>
			<div>
				<input type="checkbox" name="isaktif" id="isaktif" value="1" <? if($value['isaktif']=='1') echo 'checked'; else echo '';?>>
			</div>
			<p class="instruct">
				Pilih Aktif/Tidak Pada Kolom ini.			
			</p>
		</li>
		<?php echo form_error('isaktif'); ?>
		
		<li>
			<label class="desc">Logo Instansi</label><i>Max 500 Kb, Best Size 180x180</i>
			<div>
				<input type="file" name="userfile" size="20" />
				&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <b>Format : jpg, png, gif (max : 500kb)</b>
			</div>
			<p class="instruct">
				Masukkan Logo Instansi pada Kolom ini.			
			</p>
		</li>
		<?php echo form_error('foto'); ?>
		
		<li>
			<label class="desc"></i>
			<div>
				<?// if($fileold != ''){ echo $fileold;}else{ echo '';}?>
				<?if($fileold != ''){?>
					<img width="50" height="50" src="<?= base_url() ?>images/<?= $fileold?>"> <?php echo $fileold?>
				<?}?>
			</div>
		</li>
		
		<input type="hidden" id="fileold" name="fileold" value="<?=$fileold?>">
		<li class="buttons">
		  <input id="saveForm" class="btTxt" type="submit" value="Simpan" />
		  <input name="submit" type="reset" value="Batal" />
		</li>
	</ul>
</div>
</fieldset>
<script type="text/javascript">
  $(".chzn-select").chosen();
  $(".chzn-select-deselect").chosen({allow_single_deselect:true});
</script>	
<?= form_close(); ?>
</form>
</div><!--container-->